package com.test.mchelepesa.dialog_rice;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.ViewGroup;


import com.test.mchelepesa.R;
import com.test.mchelepesa.util_rice.http_rice.HttpManager_rice;

public class PhotoUploadDialog_rice extends Dialog {

    private final Runnable takeAPhotoRunnable,fromAlbumRunnable;

    public PhotoUploadDialog_rice(Context context,Runnable takeAPhotoRunnable,Runnable fromAlbumRunnable) {
        super(context);
        this.takeAPhotoRunnable = takeAPhotoRunnable;
        this.fromAlbumRunnable = fromAlbumRunnable;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState_pretfacile) {
        super.onCreate(savedInstanceState_pretfacile);
        setContentView(R.layout.dialog_photo_upload_rice);

        getWindow().setBackgroundDrawableResource(R.color.trans);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

        findViewById(R.id.dialog_photo_close).setOnClickListener(v -> {
            HttpManager_rice.getInstance().saveUserBuriedPoint("DIALOG_PHOTO_SELECT_CLOSE_CLICK");
            dismiss();
        });

        findViewById(R.id.dialog_photo_view_take_a_photo).setOnClickListener(v -> {
            HttpManager_rice.getInstance().saveUserBuriedPoint("DIALOG_PHOTO_SELECT_TAKE_A_PHOTO_CLICK");
            if (takeAPhotoRunnable!=null) takeAPhotoRunnable.run();
            dismiss();
        });

        findViewById(R.id.dialog_photo_view_from_album).setOnClickListener(v -> {
            HttpManager_rice.getInstance().saveUserBuriedPoint("DIALOG_PHOTO_SELECT_FROM_ALBUM_CLICK");
            if (fromAlbumRunnable!=null) fromAlbumRunnable.run();
            dismiss();
        });
    }


}
